# -*- coding: utf-8 -*-
import datetime
from projects.models import *
from django.contrib.auth.models import User
from cab.models import Snippet                           
from tagging.models import Tag
from comments.models import Comment
from news.models import News

def stats():
    snippets = Snippet.objects.all().count()
    projects = Project.objects.all().count()
    releases = Release.objects.all().count()
    screenshots = Screenshot.objects.all().count()
    videos = Video.objects.all().count()
    tags = Tag.objects.all().count()
    comments = Comment.objects.all().count()
    news = News.objects.all().count()
    users = User.objects.all().count()
    staff = User.objects.filter(is_staff=True).count()
    admins = User.objects.filter(is_superuser=True).count()
    
    now = datetime.datetime.now()
    delta1 = datetime.timedelta(weeks=1)
    delta2 = datetime.timedelta(days=365)
    # active users within the last 7 days
    users_lsd = User.objects.filter(last_login__gt=now-delta1).count()
    users_inactive = User.objects.filter(last_login__lt=now-delta1).count()
    return locals()